package com.guoheng.hazard.sys.controller.hazard;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.hazard.GetSafeOneMapDTO;
import com.guoheng.hazard.sys.service.hazard.SafeOneMapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　SafeOneMapController
 *
 * @author fbl
 * @date 2019-12-02 08:32
 */
@RestController
@Validated
@Api(value = "安全一张图")
public class SafeOneMapController {

    @Resource
    SafeOneMapService safeOneMapService;

    @ApiOperation(value = "安全一张图")
    @PostMapping(value = "data/major/hazard/maps")
    public Result getSafeOneMap(@RequestBody @Valid GetSafeOneMapDTO getSafeOneMapDTO) {
        return safeOneMapService.getSafeOneMap(getSafeOneMapDTO);
    }

    @ApiOperation(value = "实时摄像头数据")
    @GetMapping(value = "data/major/hazard/realTimeCamera/{id}")
    public Result realTimeCamera(@PathVariable @NotNull Long id) {
        return safeOneMapService.realTimeCamera(id);
    }

    @ApiOperation(value = "重大危险源数据")
    @GetMapping(value = "data/major/hazard/{id}")
    public Result majorHazard(@PathVariable Long id) {
        return safeOneMapService.majorHazard(id);
    }

    @ApiOperation(value = "时间段筛选传感器历史记录")
    @GetMapping(value = "data/major/hazard/searchSensorRecord/{id}")
    public Result searchSensorRecord(@PathVariable Long id, @NotNull Long beginTime, @NotNull Long endTime) {
        return safeOneMapService.searchSensorRecord(id, beginTime, endTime);
    }

    @ApiOperation(value = "安全一张图中各种数据的数量")
    @GetMapping(value = "data/major/hazard/safeOneMapDataNum")
    public Result safeOneMapDataNum(Long entprId) {
        return safeOneMapService.safeOneMapDataNum(entprId);
    }

    @ApiOperation(value = "安全一张图中传感器实时数据(替代webSocket)")
    @GetMapping(value = "data/major/hazard/sensorData")
    public Result sensorData(Long sensorId) {
        return safeOneMapService.sensorData(sensorId);
    }

}